package com.itheima.listeren;


import com.alibaba.fastjson.JSON;
import com.itheima.mapper.JournalMapper;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RabbitListener(queues = "spring_queue")
public class JournalListeren {


    @Autowired
    private JournalMapper journalMapper;


    @RabbitHandler
    public void handler(String content){
        Map map = JSON.parseObject(content, Map.class);
        journalMapper.addJournal(map);

    }



}
